import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DataSourceVO, DataSourceForm, DataSourceQuery } from '@/api/report/dataSource/types';

/**
 * 查询数据源管理列表
 * @param query
 * @returns {*}
 */

export const listDataSource = (query?: DataSourceQuery): AxiosPromise<DataSourceVO[]> => {
  return request({
    url: '/report/dataSource/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询数据源管理详细
 * @param id
 */
export const getDataSource = (id: string | number): AxiosPromise<DataSourceVO> => {
  return request({
    url: '/report/dataSource/' + id,
    method: 'get'
  });
};

/**
 * 新增数据源管理
 * @param data
 */
export const addDataSource = (data: DataSourceForm) => {
  return request({
    url: '/report/dataSource',
    method: 'post',
    data: data
  });
};

/**
 * 修改数据源管理
 * @param data
 */
export const updateDataSource = (data: DataSourceForm) => {
  return request({
    url: '/report/dataSource',
    method: 'put',
    data: data
  });
};

/**
 * 删除数据源管理
 * @param id
 */
export const delDataSource = (id: string | number | Array<string | number>) => {
  return request({
    url: '/report/dataSource/' + id,
    method: 'delete'
  });
};
